﻿namespace EFS.RC.CC.Config.Scheduler
{
	public class Day : EFS.Common.Serialization.ISerializable, System.Collections.Generic.IEnumerable<EFS.RC.CC.Config.Scheduler.TimeInterval>
	{
		/// <summary>
		/// Time intervals
		/// </summary>
		private EFS.RC.CC.Config.Scheduler.TimeInterval[] timeIntervals = new EFS.RC.CC.Config.Scheduler.TimeInterval[0];

		/// <summary>
		/// Time
		/// </summary>
		public Day()
		{
		}

		/// <summary>
		/// Day
		/// </summary>
		public System.DayOfWeek DayOfWeek { get; private set; }

		/// Serialize
		public virtual void Serialize(EFS.Common.Serialization.XmlWriter xmlWriter)
		{
			// write
			xmlWriter.Write("DayOfWeek", System.Enum.GetName(typeof(System.DayOfWeek), DayOfWeek));
			xmlWriter.Write<EFS.RC.CC.Config.Scheduler.TimeInterval>("TimeIntervals", "TimeInterval", timeIntervals);
		}

		/// Deserialize
		public virtual void Deserialize(EFS.Common.Serialization.XmlReader xmlReader)
		{
			// read
			DayOfWeek = (System.DayOfWeek)System.Enum.Parse(typeof(System.DayOfWeek), xmlReader.Read("DayOfWeek"));
			xmlReader.Read<EFS.RC.CC.Config.Scheduler.TimeInterval>("TimeIntervals", "TimeInterval", ref timeIntervals);
		}

		/// <summary>
		/// Get enumerator
		/// </summary>
		/// <returns></returns>
		public System.Collections.IEnumerator GetEnumerator()
		{
			return timeIntervals.GetEnumerator();
		}

		/// <summary>
		/// Get enumerator
		/// </summary>
		/// <returns></returns>
		System.Collections.Generic.IEnumerator<EFS.RC.CC.Config.Scheduler.TimeInterval> System.Collections.Generic.IEnumerable<EFS.RC.CC.Config.Scheduler.TimeInterval>.GetEnumerator()
		{
			return (System.Collections.Generic.IEnumerator<EFS.RC.CC.Config.Scheduler.TimeInterval>)timeIntervals.GetEnumerator();
		}
	}
}